<template>
  <a-layout style="height: 100%">
    <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible>
      <div class="logo"/>
      <a-menu v-model:selectedKeys="selectedKeys" theme="dark" mode="inline">
        <a-menu-item :key="item.id" v-for="item in menus" @click="handleClickMenu(item.path)">
          <user-outlined/>
          <span>{{ item.name }}</span>
        </a-menu-item>
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0">
        <menu-unfold-outlined
            v-if="collapsed"
            class="trigger"
            @click="() => (collapsed = !collapsed)"
        />
        <menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)"/>
      </a-layout-header>
      <a-layout-content
          :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
      >
        <router-view ></router-view>
<!--        <sub-app v-show="!show"></sub-app>-->
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script lang="ts">
// import {
//   UserOutlined,
//   VideoCameraOutlined,
//   UploadOutlined,
//   MenuUnfoldOutlined,
//   MenuFoldOutlined,
// } from '@ant-design/icons-vue';
import {defineComponent, ref} from 'vue';
import {useRouter} from "vue-router";
import subApp from "@/views/sub-app/SubApp.vue";

export default defineComponent({
  components: {
    // UserOutlined,
    // VideoCameraOutlined,
    // UploadOutlined,
    // MenuUnfoldOutlined,
    // MenuFoldOutlined,
    subApp
  },
  setup() {
    interface Menus {
      path: String,
      name: String,
      id: Number | String
    }

    const show = ref<boolean>(false)
    const router = useRouter()

    const menus = ref<Menus[]>([
      {
        id: 1,
        path: '/main-vite/enterpriseInfo',
        name: '企业信息'
      },
      {
        id: 2,
        path: '/main-vite/enterpriseStaff',
        name: '企业员工'
      },
      {
        id: '3',
        path: '/main-vite/enterpriseFinance',
        name: '企业财务'
      },
      {
        id: '4',
        path: '/main-vite/app-vite#/child/vite/roles2',
        name: '子应用'
      },
    ])
    const handleClickMenu = (path: string): void => {
      // if (path === '/app-vite') {
      //   show.value = false
      // } else {
      console.log(path)
        show.value = true
        router.push(
          path )
      // }

    }
    return {
      selectedKeys: ref<string[]>(['1']),
      collapsed: ref<boolean>(false),
      menus,
      handleClickMenu,
      show
    };
  },
});
</script>

<style scoped>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.3);
  margin: 16px;
}

.site-layout .site-layout-background {
  background: #fff;
}
</style>
